package com.dnjn.happiness.survey.controller.admin;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dnjn.happiness.survey.controller.common.CommonCheckQuestionController;
import com.dnjn.happiness.survey.domain.CheckQuestion;
import com.dnjn.happiness.survey.domain.vo.CheckQuestionVO;
import com.dnjn.happiness.common.log.annotation.Log;
import com.dnjn.happiness.common.log.enums.BusinessType;
import com.dnjn.happiness.common.core.utils.bean.BeanUtils;
import com.dnjn.happiness.common.core.utils.poi.ExcelUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.dnjn.happiness.common.security.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 考核题目Controller
 *
 * @author happiness
 * @date 2024-04-02
 */
@Tag(name = "check admin question 考核题目" , description = "考核题目" )
@RestController
@RequestMapping("/admin/check/question" )
public class AdminCheckQuestionController extends CommonCheckQuestionController {
    /**
     * 导出考核题目列表
     */
    @Log(title = "考核题目" , businessType = BusinessType.EXPORT)
    @RequiresPermissions("@ss.hasPermi('check:question:export')" )
    @PostMapping("/export" )
    public void export(HttpServletResponse response, CheckQuestionVO vo) {
        CheckQuestion checkQuestion=new CheckQuestion();
        BeanUtils.copyPropsIgnoreNull(vo,checkQuestion);

        List<CheckQuestion> list = checkQuestionService.list(Wrappers.query(checkQuestion));
        ExcelUtil<CheckQuestion> util = new ExcelUtil<CheckQuestion>(CheckQuestion. class);
        util.exportExcel(response, list, "考核题目数据" );
    }


}
